<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta name="Content-Type" content="text/html; charset=UTF-8" />
<title>Class: Sass::Script::Lexer</title>
<link rel="stylesheet" href="style.css" tppabs="http://sass-lang.com/docs/yardoc/css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="common.css" tppabs="http://sass-lang.com/docs/yardoc/css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '../..';
  if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="jquery.js" tppabs="http://sass-lang.com/docs/yardoc/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="app.js" tppabs="http://sass-lang.com/docs/yardoc/js/app.js"></script>

  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html" tppabs="http://sass-lang.com/docs/yardoc/_index.html">Index (L)</a> &raquo; 
    <span class='title'><a href="Sass-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass.html" title="Sass (module)">Sass</a></span> &raquo; <span class='title'><a href="Script.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script.html" title="Sass::Script (module)">Script</a></span>
     &raquo; 
    <span class="title">Lexer</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="javascript:if(confirm(%27http://sass-lang.com/docs/yardoc/Sass/Script/.  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?%27))window.location=%27http://sass-lang.com/docs/yardoc/Sass/Script/.%27" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  <a id="class_list_link" href="#">Class List</a>
  <a id="method_list_link" href="#">Method List</a>
  <a id ="file_list_link" href="#">File List</a>
</div>

      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: Sass::Script::Lexer 
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Sass::Script::Lexer</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
      <dt class="r2">Includes:</dt>
      <dd class="r2"><a href="RX.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/SCSS/RX.html" title="Sass::SCSS::RX (module)">Sass::SCSS::RX</a></dd>
      
    
  
  
    <dt class="r1 last">Defined in:</dt>
    <dd class="r1 last">/var/www/sass-pages/.sass/lib/sass/script/lexer.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>The lexical analyzer for SassScript. It takes a raw string and converts it to individual tokens that are easier to parse.</p>

  </div>
</div>
<div class="tags">
  
</div><div id="subclasses">
  <h2>Direct Known Subclasses</h2>
  <p class="children"><a href="CssLexer.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/CssLexer.html" title="Sass::Script::CssLexer (class)">CssLexer</a></p>
</div>

  <h2>Constant Summary</h2>
  


  
  
  
  
  <h2>Instance Attribute Summary</h2>
  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#line-instance_method" title="#line (instance method)">- (Fixnum) <strong>line</strong> </a>
    

    
  </span>
  
  
    <span class="note title readonly">readonly</span>
    
  
  
  
  

  
    <span class="summary_desc">The line number of the lexer&#8217;s current position.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#offset-instance_method" title="#offset (instance method)">- (Fixnum) <strong>offset</strong> </a>
    

    
  </span>
  
  
    <span class="note title readonly">readonly</span>
    
  
  
  
  

  
    <span class="summary_desc">The number of bytes into the current line of the lexer&#8217;s current position.</span>
  
</li>

    
  </ul>


  <h2>Instance Method Summary</h2>

  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#after_interpolation%3F-instance_method" title="#after_interpolation? (instance method)">- (Boolean) <strong>after_interpolation?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Whether or not the last token lexed was <code>:end_interpolation</code>.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#done%3F-instance_method" title="#done? (instance method)">- (Boolean) <strong>done?</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Whether or not there&#8217;s more source text to lex.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#expected%21-instance_method" title="#expected! (instance method)">- <strong>expected!</strong>(name) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Raise an error to the effect that <code>name</code> was expected in the input stream and wasn&#8217;t found.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (Lexer) <strong>initialize</strong>(str, line, offset, options) </a>
    

    
  </span>
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  

  
    <span class="summary_desc">A new instance of Lexer.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#next-instance_method" title="#next (instance method)">- (Token) <strong>next</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Moves the lexer forward one token.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#peek-instance_method" title="#peek (instance method)">- (Token) <strong>peek</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns the next token without moving the lexer forward.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#str-instance_method" title="#str (instance method)">- (String) <strong>str</strong> { ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Records all non-comment text the lexer consumes within the block and returns it as a string.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#unpeek%21-instance_method" title="#unpeek! (instance method)">- <strong>unpeek!</strong> </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Rewinds the underlying StringScanner to before the token returned by <tt><a href="#peek-instance_method" title="Sass::Script::Lexer#peek (method)">#peek</a></tt>.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#whitespace%3F-instance_method" title="#whitespace? (instance method)">- (Boolean) <strong>whitespace?</strong>(tok = @tok) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Returns whether or not there&#8217;s whitespace before the next token.</span>
  
</li>

    
  </ul>

  
  
  
  
  
  <h3 class="inherited">Methods included from <a href="RX.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/SCSS/RX.html" title="Sass::SCSS::RX (module)">Sass::SCSS::RX</a></h3>
  <p class="inherited"><a href="RX.html#escape_ident-class_method" tppabs="http://sass-lang.com/docs/yardoc/Sass/SCSS/RX.html#escape_ident-class_method" title="Sass::SCSS::RX.escape_ident (method)">escape_ident</a></p>
<div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <p class="signature first" id="initialize-instance_method">
  
    - (<tt><a href="" title="Sass::Script::Lexer (class)">Lexer</a></tt>) <strong>initialize</strong>(str, line, offset, options) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>A new instance of Lexer</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt><a href="String.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/String.html" title="Sass::Script::String (class)">String</a></tt>, <tt>StringScanner</tt>)</span>
      
      
        <span class='name'>str</span>
      
      
      
        &mdash;
        The source text to lex
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
        <span class='name'>line</span>
      
      
      
        &mdash;
        The line on which the SassScript appears. Used for error reporting
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
        <span class='name'>offset</span>
      
      
      
        &mdash;
        The number of characters in on which the SassScript appears. Used for error reporting
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>{Symbol =&gt; Object}</tt>)</span>
      
      
        <span class='name'>options</span>
      
      
      
        &mdash;
        An options hash; see <a href="file.SASS_REFERENCE.html#sass_options" tppabs="http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#sass_options" title="the Sass options documentation">the Sass options documentation</a>
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


134
135
136
137
138
139
140
141</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/script/lexer.rb', line 134</span>

def initialize(str, line, offset, options)
  @scanner = str.is_a?(StringScanner) ? str : Sass::Util::MultibyteStringScanner.new(str)
  @line = line
  @offset = offset
  @options = options
  @interpolation_stack = []
  @prev = nil
end</pre>
    </td>
  </tr>
</table>
</div>
  
</div>

  <div id="instance_attr_details" class="attr_details">
    <h2>Instance Attribute Details</h2>
    
      
      <span id=""></span>
      <span id="line-instance_method"></span>
      <div class="method_details first">
  <p class="signature first" id="line-instance_method">
  
    - (<tt>Fixnum</tt>) <strong>line</strong>  <span class="extras">(readonly)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>The line number of the lexer&#8217;s current position.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


32
33
34</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/script/lexer.rb', line 32</span>

def line
  @line
end</pre>
    </td>
  </tr>
</table>
</div>
    
      
      <span id=""></span>
      <span id="offset-instance_method"></span>
      <div class="method_details ">
  <p class="signature " id="offset-instance_method">
  
    - (<tt>Fixnum</tt>) <strong>offset</strong>  <span class="extras">(readonly)</span>
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>The number of bytes into the current line of the lexer&#8217;s current position.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


38
39
40</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/script/lexer.rb', line 38</span>

def offset
  @offset
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="after_interpolation?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>after_interpolation?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Whether or not the last token lexed was <code>:end_interpolation</code>.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
        &mdash;
        Whether or not the last token lexed was <code>:end_interpolation</code>.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


185
186
187</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/script/lexer.rb', line 185</span>

def after_interpolation?
  @prev && @prev.type == :end_interpolation
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="done?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>done?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Whether or not there&#8217;s more source text to lex.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
        &mdash;
        Whether or not there&#8217;s more source text to lex.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


179
180
181
182</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/script/lexer.rb', line 179</span>

def done?
  whitespace unless after_interpolation? && @interpolation_stack.last
  @scanner.eos? && @tok.nil?
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="expected!-instance_method">
  
    - <strong>expected!</strong>(name) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Raise an error to the effect that <code>name</code> was expected in the input stream and wasn&#8217;t found.</p>

<p>This calls <tt><a href="#unpeek%21-instance_method" title="Sass::Script::Lexer#unpeek! (method)">#unpeek!</a></tt> to rewind the scanner to immediately after the last returned token.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt><a href="String.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/String.html" title="Sass::Script::String (class)">String</a></tt>)</span>
      
      
        <span class='name'>name</span>
      
      
      
        &mdash;
        The name of the entity that was expected but not found
      
    </li>
  
</ul>
<h3>Raises:</h3>
<ul class="raise">
  
    <li>
      
        <span class='type'>(<tt><a href="SyntaxError.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/SyntaxError.html" title="Sass::SyntaxError (class)">Sass::SyntaxError</a></tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


197
198
199
200</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/script/lexer.rb', line 197</span>

def expected!(name)
  unpeek!
  Sass::SCSS::Parser.expected(@scanner, name, @line)
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="next-instance_method">
  
    - (<tt><a href="Token.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/Lexer/Token.html" title="Sass::Script::Lexer::Token (class)">Token</a></tt>) <strong>next</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Moves the lexer forward one token.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt><a href="Token.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/Lexer/Token.html" title="Sass::Script::Lexer::Token (class)">Token</a></tt>)</span>
      
      
      
      
        &mdash;
        The token that was moved past
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


146
147
148
149
150
151</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/script/lexer.rb', line 146</span>

def next
  @tok ||= read_token
  @tok, tok = nil, @tok
  @prev = tok
  return tok
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="peek-instance_method">
  
    - (<tt><a href="Token.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/Lexer/Token.html" title="Sass::Script::Lexer::Token (class)">Token</a></tt>) <strong>peek</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns the next token without moving the lexer forward.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt><a href="Token.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/Lexer/Token.html" title="Sass::Script::Lexer::Token (class)">Token</a></tt>)</span>
      
      
      
      
        &mdash;
        The next token
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


168
169
170</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/script/lexer.rb', line 168</span>

def peek
  @tok ||= read_token
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="str-instance_method">
  
    - (<tt><a href="String.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/String.html" title="Sass::Script::String (class)">String</a></tt>) <strong>str</strong> { ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Records all non-comment text the lexer consumes within the block and returns it as a string.</p>

  </div>
</div>
<div class="tags">
  <h3>Yields:</h3>
<ul class="yield">
  
    <li>
      
        <span class='type'></span>
      
      
      
      
        
        A block in which text is recorded
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt><a href="String.html" tppabs="http://sass-lang.com/docs/yardoc/Sass/Script/String.html" title="Sass::Script::String (class)">String</a></tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


207
208
209
210
211
212</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/script/lexer.rb', line 207</span>

def str
  old_pos = @tok ? @tok.pos : @scanner.pos
  yield
  new_pos = @tok ? @tok.pos : @scanner.pos
  @scanner.string[old_pos...new_pos]
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="unpeek!-instance_method">
  
    - <strong>unpeek!</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Rewinds the underlying StringScanner to before the token returned by <tt><a href="#peek-instance_method" title="Sass::Script::Lexer#peek (method)">#peek</a></tt>.</p>

  </div>
</div>
<div class="tags">
  
</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


174
175
176</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/script/lexer.rb', line 174</span>

def unpeek!
  @scanner.pos = @tok.pos if @tok
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="whitespace?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>whitespace?</strong>(tok = @tok) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Returns whether or not there&#8217;s whitespace before the next token.</p>

  </div>
</div>
<div class="tags">
  <h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


156
157
158
159
160
161
162
163</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/script/lexer.rb', line 156</span>

def whitespace?(tok = @tok)
  if tok
    @scanner.string[0...tok.pos] =~ /\s\Z/
  else
    @scanner.string[@scanner.pos, 1] =~ /^\s/ ||
      @scanner.string[@scanner.pos - 1, 1] =~ /\s\Z/
  end
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Fri Mar  8 20:34:02 2013 by 
  <a href="javascript:if(confirm(%27http://yardoc.org/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?%27))window.location=%27http://yardoc.org/%27" tppabs="http://yardoc.org/" title="Yay! A Ruby Documentation Tool">yard</a>
  0.5.3 (ruby-1.8.7).
</div>


  <script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
  try {
  var pageTracker = _gat._getTracker("UA-535380-8");
  pageTracker._trackPageview();
  } catch(err) {}</script>


  </body>
</html>